package cn.jdy.plugins.web;

import cn.jdy.platform.entity.ConfValue;
import cn.jdy.platform.service.ConfService;
import cn.jdy.plugins.entity.Company;
import cn.jdy.plugins.entity.CompanyContext;
import cn.jdy.plugins.service.AttachmentService;
import cn.jdy.plugins.service.BrandCreditService;
import cn.jdy.plugins.service.CompanyContextService;
import cn.jdy.plugins.service.CompanyService;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Controller
@RequestMapping("/company")
public class CompanyCtrl {

	@Autowired
	private CompanyService companyService;
	@Autowired
	private CompanyContextService companyContextService;
	@Autowired
	private BrandCreditService brandCreditService;
	@Autowired
	private AttachmentService attchmentService;
	@Autowired
	private ConfService confService;

	@RequestMapping("/getCompanyInfoById")
	@ResponseBody
	public Map<String, Object> getCompanyInfoById(String companyId) {
		Map<String, Object> jsonMap = new HashMap<String, Object>();
		Company company = companyService.find(companyId);
		CompanyContext companyContext = companyContextService.findOne("companyId", companyId);
		jsonMap.put("company", company);
		jsonMap.put("companyContext", companyContext);
		return jsonMap;
	}

	@RequestMapping(value = "/searchCompany")
	public ModelAndView search() {
		ModelAndView mv = new ModelAndView("/company/searchlist.jsp");
		// 查询商机分类信息
		List<ConfValue> businessclassList = confService.queryByType(8, 0L);// 商机分类： 8  放常量
		mv.addObject("businessclassList", businessclassList);
		return mv;
	}
	
  /**
   * 风险预警
   */
  @RequestMapping(value = "/riskwarn")
  public ModelAndView exposed(String type) {
    ModelAndView mv = new ModelAndView("/company/riskwarn.jsp");
    
    if (type==null) {
      type = "8004";
    }
    mv.addObject("type", type);
    
    return mv;
  }
	
}
